package com.ww.springboot.boot.baseTest.反射.simple;

import com.ww.springboot.boot.baseTest.反射.dto.Person;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2022-06-29 17:54
 */
public class SimpleDemo {


    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
        Person person = new Person();

        Class clazz = person.getClass();

        Method[] methods = clazz.getMethods();
        for (Method method : methods) {
            if(method.getName().contains("setName")){
                method.invoke(person,333);
                break;
            }
        }

        System.out.println(person.toString());
    }
}
